package hasthi.common;

import hasthi.instrument.JavaInstrumentation;

import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Date;

public class ErrorManager {
    private static PrintWriter errorOut;
    public static void error(Throwable e){
        if(errorOut == null){
            try {
                errorOut = new PrintWriter("error.log");
            } catch (FileNotFoundException e1) {
                e1.printStackTrace();
            }
        }
        errorOut.write("[Error]"+new Date(System.currentTimeMillis()) + ":"+Utils.getLocalHost() + ":"+JavaInstrumentation.getMemoryUsage()+" ");
        e.printStackTrace(errorOut);
        errorOut.flush();
    }
}
